<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller{

	//生成验证码的图片
	   public function check_code(){
	   	  $config = array(
	   	  	'font-size'=>30,   //字体大小
	   	  	'length'   =>3,   //验证码位数
	   	  	'useNoise' =>false,  //关闭验证码咋点
	   	  );
	   	  $Verify =     new \Think\Verify($config);
	   	  $Verify->entry();
	   	  
	   }
	  //注册的方法
	  public function regist(){
	  	 // var_dump(I('post.'));die();
	  	 if(IS_POST){
	  	 	 $model = D('Admin/Member');
	  	 	if($model->create(I('post.'),1)){
	  	 		
	  	 		if($model->add()){
	  	 			$this->success('注册成功',U('Home/Index/index'));
	  	 			exit;
	  	 		}
	  	 	}
	  	 	$this->error($model->getError());
	  	 }
	  	 $this->display();
	  }
	 public function login(){
	 	if(IS_POST){
	 		$model = D('Admin/Member');
	 		if($model->validate($model->_login_validate)->create(I('post.'),1)){
	 			if($model->login()){
	 				//
	 				$return = session('returnURL');
	 				if($return){
	 					session('returnURL',null);
	 					$this->success('登录成功',$return);
	 					exit;
	 				}else{
	 				    $this->success('登录成功,呀',U('Home/Index/index'));
	 				    exit;
	 				}
	 			}
	 		}
	 		$this->error($model->getError());
	 	}
	 	$this->display();
	 }
    //退出
    public function loginout(){
    	session(null);
    	redirect('/');
    }


}